/*************************************************
Author: Aven 
Date: 2/28/2013
Description:
Notes: 
*************************************************/

#ifndef __CPetMgr_h__
#define __CPetMgr_h__

#include "CPetConfig.h"
#include "CUserPet.h"
#include "MsgPet.pb.h"
#include "MsgPartnerInfo.pb.h"

//typedef CTLib::CTArray<int, 50>  FruitAwardArray;

class CPetMgr
{
public:
	CPetMgr()
    {
	}

	virtual ~CPetMgr() 
    {
	}

    int Init();
    int LoadConfig(const char* szLogPath);

    //宠物探险
    int PetExplore(CUserPet& stUserPet, MsgAnsPetOther& stAns);

    int GeneratePet(CUserPet& stUserPet, unsigned char _ucCareer);

    int TriggerExploreAward(CUserPet& stUserPet, CPetExploreConfigData& stConfigData);
    int TriggerExploreAwardWithLevel(short iLevel, CUserPet& stUserPet, CPetExploreConfigData& stConfigData, CDropItem& stDropItem);

    int GetPetStarConfig(CUserPet& stUserPet, CPetStarConfigData & stData);

    int GetPetStarConfig(int iLevel, int iStar, CPetStarConfigData & stData);

    int PetTrainKouLiangBatch(CUserPet& stUserPet, int iTrainNums, MsgAnsPetTrain&  stAns);

    int DesignLevelStarUpdate( int & iLevel, int & iStar, int & iCurExper, FruitAwardArray & aAwardFruits );
    int DesignLevelStarUpdateOneTime( int & iLevel, int & iStar, int & iCurExper, FruitAwardArray & aAwardFruits );

    bool ConsumeRand(int uiMax, int uiRateVal);

    int GetPetLevelStarFruit(CUserPet& stUserPet, int & iLevel, int& iStar, int& iFruitNum);

    //宠物口粮培养
    int PetTrainKouLiang(CUserPet& stUserPet, int iKouLiangNum, int iGridPos, MsgAnsPetTrain& stAns);

    int PetClearCDTime(CUserPet& stUserPet);

    int CheckPetTrain( CUserPet& stUserPet );

    //金币培养
    int PetTrainGold(CUserPet& stUserPet, int iGoldNum);

    //检查星级和等阶的升级
    int CheckPetUpdate(CUserPet& stUserPet);

    //银币培养
    int PetTrainSilver(CUserPet& stUserPet, int iSilverNum, MsgAnsPetTrain&  stAns);

    //广播类型,type=1, 宠物等阶升级， type=2,宠物获得大暴击
    int PetBroadcast(CUserPet& stUserPet, int type);

    //果实培养
    int PetTrainFruit(CUserPet& stUserPet, int iFruitNum, int iGridPos);

    //改变宠物形态
    int PetChangeStyle(CUserPet& stUserPet, int iPetNewStyle);

    int PetEnableNewStyle(CUserPet& stUserPet, int iPetNewStyle);

    //升等阶
    int PetReqUpdateLevel(CUserPet& stUserPet);

    //领取果实
    int PetRecvFruit(CUserPet& stUserPet);


    int GetPetInfo(CUserPet& stUserPet, MsgAnsPetInfo& stPetInfoAns);

	int GetPetAttrInfo(CUserPet & stUserPet, MsgPet& stMsgPetInfo);

    int GetPetId(CUserPet& stUserPet, int &iPetId);

    int GetPetAttr(CUserPet& stUserPet, CPlayerAttr& astPetAttrs);

    int CheckNewPetName(CTSizeString<PETNAME_LEN>& szPetName);

    int GetPetExploreConfigCounts();

    ExploreRandArray & GetExploreRandArray();

    //GM Command
    int GMPetTrain(CUserPet& stUserPet, int iTrainExper);

private:
	CPetConfig _stPetConfig;

    ExploreRandArray m_aiExploreConfigEventRand;
};


#endif // __CPetMgr_h__

